<?php 
// echo "<pre>";
// print_r($dados);
// echo "</pre>";
// exit;
?>
<script>
$(document).ready(function(){
	$('#bt_buscar').live('click', function(){
		$('#frmBuscar').serialize();
		$('#frmBuscar').submit();
	});
});

</script>

	<span class="saudacao">
		Seja bem vindo:
		<?php
		echo $this->session->userdata('usuario');
		echo " | ";
		echo anchor( base_url() . 'principal/logout', 'Sair', 'title="Efetuar Logout"');
		?>
	</span>
      <h1>Produtos</h1>
      	<form id="frmBuscar" name="frmBuscar" method="post" action="<?php echo base_url()."produto";?>">
      		<label>Nome:</label>
      		<?php 
			if (isset($dados['busca']) && $dados['busca'] != "" ) { 
				$busca = $dados['busca'];
			} else {
				$busca = "";
			}?>
			<input id="strBusca" name="strBusca" type="text" style="width:148px;" value="<?php echo $busca;?>" />
			
			<input type="hidden" name="strOrdenacao" id="strOrdenacao" value="cli_nome" />
			<input type="hidden" name="strModoOrdenacao" id="strModoOrdenacao" value="desc" />

			<?php 
			if (isset($dados['status']) && $dados['status'] != "" ) { 
				$status = $dados['status'];
			} else {
				$status = 1;
			}?>
			<label>Status:</label>
			<input type="radio" id="ativo" name="intStatus" value="1" <?php if ($status == 1){ echo "checked='checked'"; }?> />Ativo
			<input type="radio" id="inativo" name="intStatus" value="0" <?php if ($status == 0){ echo "checked='checked'"; }?>/> Inativo
			
			<input id="bt_buscar" name="bt_buscar" type="button" value="ok" />
		</form>
		<form action="" method="post" enctype="multipart/form-data" id="form">
			<table class="list">
				<tr>
					<td class='left' width="30"><a href="javascript:void(0);" >Id</a></td>
					<td class='left' width="100"><a href="javascript:void(0);" class="ordenar" id="cli_nome">Nome</a></td>
					<td class='left' width="100" style="text-align:center">CNPJ</td>
					<td class='left' width="100" style="text-align:center">Endereço</td>
					<td class='left' width="100" style="text-align:center">Cidade</td>
					<td class='left' width="100" style="text-align:center">Bairro</td>
					<td class='left' width="100" style="text-align:center">CEP</td>
					<td class='left' width="100" style="text-align:center">DDD</td>
					<td class='left' width="100" style="text-align:center">Telefone</td>
					<td class='left' width="100" style="text-align:center">E-mail</td>
					<td class='left' width="100" style="text-align:center">Contato</td>
					<td class='left' width="100" style="text-align:center">Site</td>
					<td class='left' width="100" style="text-align:center">Data do Cadastro</td>
					<td class='left' width="60" style="text-align:center">Status</td>
					<td class='left' width="60" style="text-align:center">Excluído</td>
				</tr>
			</table>
			<table>
				<?php 
				if ( isset($dados['cliente']) && $dados['cliente'] != "" ){
					foreach ($dados['cliente'] as $cliente){
				?>
				<tr>
					<td class='left'>
						<a href='<?php echo base_url() . "usuario/".$cliente->cli_id; ?>'><?php echo $cliente->cli_id;?></a>
					</td>
					<td class='left' width="100">
						<a href="javascript:void(0);" class="ordenar" id="usu_nome"><?php echo $cliente->cli_nome;?></a>
					</td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_cnpj;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_endereco;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_cidade;?></td><td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_bairro;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_cep;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_ddd;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_telefone;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_email;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_contato;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_site;?></td>
					<td class='left' width="100" style="text-align:center"><?php echo $cliente->cli_dataCadastro;?></td>
					<td class='left' width="60" style="text-align:center"><?php echo $cliente->cli_status;?></td>
					<td class='left' width="60" style="text-align:center"><?php echo $cliente->cli_excluido;?></td>
					
					<td class='left'>
						<a href='<?php echo base_url() . "cliente/telaAlterarCliente/" . $cliente->cli_id; ?>'>Alterar</a>
					</td>
					
					<td class='left'>
						<a href='<?php echo base_url() . "cliente/excluirCliente/" . $cliente->cli_id; ?>'>Excluir</a>
					</td>
				</tr>
				<?php 
					} 
				}
				?>
			</table>
		</form>
	<table>
		<tr>
			<td class='left'>
				<a href='<?php echo base_url() . "cliente/telaAdicionarCliente";?>'>Adicionar Cliente</a>
			</td>
		</tr>
	</table>

